﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.CUiExportToRTRWindowGenericCommand`1
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;


namespace DnProcessSimulateCommands.ExportToRTR{

public class CUiExportToRTRWindowGenericCommand<T> : CUiExportToRTRWindowBaseCommand
{
  private readonly Action<T> _execute;
  private readonly Func<bool> _canExecute;

  public CUiExportToRTRWindowGenericCommand(Action<T> execute)
    : this(execute, (Func<bool>) null)
  {
  }

  public CUiExportToRTRWindowGenericCommand(Action<T> execute, Func<bool> canExecute)
  {
    this._execute = execute ?? throw new ArgumentNullException("Execute can't be null");
    this._canExecute = canExecute;
  }

  public override bool CanExecute(object parameter)
  {
    return this._canExecute == null || this._canExecute();
  }

  public override void Execute(object parameter)
  {
    if (!(parameter is T obj))
      return;
    this._execute(obj);
  }
}
